package com.hzy.yiyaoba.utils;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Environment;

public class CommonUtils {

	public static final String TEMP_DIR = "/yiyaoba/temp";

	public static String getTempPath() {
		String tempPath = null;
		if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
			tempPath = Environment.getExternalStorageDirectory().getAbsolutePath() + TEMP_DIR;
		} else {
			tempPath = Environment.getDataDirectory().getAbsolutePath() + TEMP_DIR;
		}
		return tempPath;
	}

	public static String getAppName(Context context) {
		PackageManager pkgMgr = context.getPackageManager();
		try {
			PackageInfo info = pkgMgr.getPackageInfo(context.getPackageName(), 0);
			return info.applicationInfo.loadLabel(pkgMgr).toString();
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
		return "";
	}
}
